import and prep data
data viz 1
# Visualize the relationship between trust in government and likelihood of compliance with government policies, introducing country as a third variable. I think this would work well as a line plot or scatterplot, with different countries in different colors.
viz_1 <- covid_data %>%
ggplot(aes(trust, gov_comp)) +
geom_smooth(aes(colour = country_of_residence),
size = 0.5) +
facet_wrap(~country_of_residence) +
theme_minimal() +
scale_color_viridis_d() +
xlab("Trust in government") +
ylab("Compliance with government policies") +
labs(title = "Greater trust in government differentially predicts higher compliance")
viz_1
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

data viz 2
# Visualize the distribution of adoption of preventive behaviors by country. I think this would work well as a ridgeline plot or boxplots.
viridis(n = 9)
## [1] "#440154FF" "#472D7BFF" "#3B528BFF" "#2C728EFF" "#21908CFF" "#27AD81FF"
## [7] "#5DC863FF" "#AADC32FF" "#FDE725FF"
viz_2 <- covid_data %>%
mutate(country_of_residence = fct_relevel(country_of_residence, "Australia", "USA", "Argentina", "Saudi Arabia", "Mexico", "Egypt", "China", "Nigeria", "India")) %>%
ggplot(aes(prevent, country_of_residence)) +
ggridges::geom_density_ridges(aes(fill = country_of_residence),
bandwidth = 0.6,
alpha = 0.5,
scale = 1.5) +
scale_fill_manual(values = c("#440154FF", "#472D7BFF", "#3B528BFF", "#2C728EFF", "#21908CFF", "#27AD81FF", "#5DC863FF", "#AADC32FF", "#FDE725FF")) +
theme_minimal() +
theme(legend.position = "none") +
xlab("Number of preventive behaviors adopted") +
ylab("") +
labs(title = "Adoption of preventive behaviors by country")
viz_2

data viz 3
# Visualize the overlap between each of the predictor variables (trust in gov/perception of gov preparedness/perception of gov performance/risk perception/perceived controllability). I think this would work well as a heatmap or correlogram.
data_for_cor <- covid_data %>%
dplyr::select(c(trust, gov_perf, gov_prep, risk, control))
cor <- as.matrix(cor(data_for_cor))
viz_3 <- heatmaply(cor,
colors = viridis(n = 256, alpha = 1, begin = 1, end = 0),
dendrogram = "none",
grid_color = "white",
margins = c(60,100,50,20),
fontsize_col = 8,
fontsize_row = 8,
labCol = colnames(cor),
labRow = rownames(cor),
xlab = "",
ylab = "",
main = "Correlational heatmap of predictor variables",
heatmap_layers = theme(axis.line=element_blank()))
viz_3
# I could do this on an item level...
data_for_cor_full <- covid_data %>%
select(contains("perceived_control"),
contains("risk_perception"),
contains("trust_in_gov"),
contains("gov_preparedness"),
contains("gov_performance"))
cor_full <- as.matrix(cor(data_for_cor_full))
viz_3_full <- heatmaply(cor_full,
colors = viridis(n = 256, alpha = 1, begin = 1, end = 0),
dendrogram = "none",
grid_color = "white",
margins = c(60,100,50,20),
fontsize_col = 8,
fontsize_row = 8,
labCol = colnames(cor_full),
labRow = rownames(cor_full),
xlab = "",
ylab = "",
main = "Correlational heatmap of predictor variables",
heatmap_layers = theme(axis.line=element_blank()))
viz_3_full